package com.codeoss.framework.view.parser;

import org.springframework.stereotype.Service;

import com.codeoss.framework.view.component.Component;
import com.codeoss.framework.view.component.TableColumn;
import com.fasterxml.jackson.databind.node.ObjectNode;

@Service("tablecolumnParser")
public class TableColumnParser extends AbstractComponentParser {
	protected void setAttributes(IParseContext parseContext, ObjectNode objectNode,Component component) {
		super.setAttributes(parseContext, objectNode, component);
		TableColumn tableColumn=(TableColumn)component;
		String title=objectNode.get("title").asText();
		tableColumn.setTitle(title);
		ObjectNode propertyMapNode=(ObjectNode)objectNode.get("propertyMap");
		if(propertyMapNode!=null) {
			if(propertyMapNode.get("fixed")!=null) {
				tableColumn.setFixed(propertyMapNode.get("fixed").asBoolean());
			}
		}
	}
	
	@Override
	protected Component createComponent(IParseContext parseContext, ObjectNode objectNode) {
		// TODO Auto-generated method stub
		return new TableColumn();
	}

}
